/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "TrancheAge")
@NamedQueries({
    @NamedQuery(name = "TrancheAge.findAll", query = "SELECT t FROM TrancheAge t"),
    @NamedQuery(name = "TrancheAge.findByAgeMin", query = "SELECT t FROM TrancheAge t WHERE t.trancheAgePK.ageMin = :ageMin"),
    @NamedQuery(name = "TrancheAge.findByAgeMax", query = "SELECT t FROM TrancheAge t WHERE t.trancheAgePK.ageMax = :ageMax"),
    @NamedQuery(name = "TrancheAge.findByCoefMontantAdhesionAgedepend", query = "SELECT t FROM TrancheAge t WHERE t.coefMontantAdhesionAgedepend = :coefMontantAdhesionAgedepend")})
public class TrancheAge implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TrancheAgePK trancheAgePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CoefMontantAdhesionAgedepend", nullable = false)
    private float coefMontantAdhesionAgedepend;

    public TrancheAge() {
    }

    public TrancheAge(TrancheAgePK trancheAgePK) {
        this.trancheAgePK = trancheAgePK;
    }

    public TrancheAge(TrancheAgePK trancheAgePK, float coefMontantAdhesionAgedepend) {
        this.trancheAgePK = trancheAgePK;
        this.coefMontantAdhesionAgedepend = coefMontantAdhesionAgedepend;
    }

    public TrancheAge(int ageMin, int ageMax) {
        this.trancheAgePK = new TrancheAgePK(ageMin, ageMax);
    }

    public TrancheAgePK getTrancheAgePK() {
        return trancheAgePK;
    }

    public void setTrancheAgePK(TrancheAgePK trancheAgePK) {
        this.trancheAgePK = trancheAgePK;
    }

    public float getCoefMontantAdhesionAgedepend() {
        return coefMontantAdhesionAgedepend;
    }

    public void setCoefMontantAdhesionAgedepend(float coefMontantAdhesionAgedepend) {
        this.coefMontantAdhesionAgedepend = coefMontantAdhesionAgedepend;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (trancheAgePK != null ? trancheAgePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TrancheAge)) {
            return false;
        }
        TrancheAge other = (TrancheAge) object;
        if ((this.trancheAgePK == null && other.trancheAgePK != null) || (this.trancheAgePK != null && !this.trancheAgePK.equals(other.trancheAgePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.TrancheAge[ trancheAgePK=" + trancheAgePK + " ]";
    }
    
}
